package es.ats.codington.festival.utils.Query;

import java.sql.*;

import es.ats.codington.festival.utils.FERSDataConnection.FersDC;

public class SelectFersDC {

	public static void main(String[] args) {
		
		try{
			//Obtaining a connection
			Connection con = FersDC.getConnection();
			if(con != null)
			{
			System.out.println("Connection successfully established!");
			}
			
			//Creating a PreparedStatement with a query "select * from Employee" 
			PreparedStatement pStmt = con.prepareStatement("select * from zoo");
			
			//Executing this query using executeQuery()
			ResultSet rs = pStmt.executeQuery();
			
			//Process the resultSet and print all records on console
			System.out.println("acuarium       idzoo");
			while(rs.next())
			{
				System.out.println(rs.getString(1)+"               "+ rs.getString(2));
				
			}
			//Closing the connection
			con.close();
		
		}catch (Exception e){
			System.out.println(e.getMessage());
		}
	}
}

